import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import AutoImport from 'unplugin-auto-import/vite'
import path from 'path'

export default defineConfig({
  transpileDependencies: ['uview-plus'],
  // 加上下面的配置

  resolve: {
    alias: {
      //别名配置
      '~': path.resolve(__dirname, './'), //配置的别名
      '@': path.resolve(__dirname, './src')
    },
    //共享配置 https://cn.vitejs.dev/config/shared-options.html#resolve-extensions
    extensions: ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json', '.vue']
  },
  define: {
    'process.env': process.env
  },
  plugins: [
    uni(),
    AutoImport({
      include: [
        /\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
        /\.vue$/,
        /\.vue\?vue/ // .vue
      ],
      imports: ['vue', 'uni-app', 'pinia'],
      dts: 'typings/auto-imports.d.ts'
    })
  ]
})
